//
//  TZNewPaswordController.m
//  wangYiLottery
//
//  Created by mac on 16/2/21.
//  Copyright © 2016年 tz. All rights reserved.
//

#import "TZResetPasswordController.h"
#import "TZSuccessLoginController.h"

@interface TZResetPasswordController ()
@property (nonatomic, strong) UIView *resetPasswordView;
@property (nonatomic, strong) UIView *againResetPasswordView;
@property (nonatomic, strong) UIButton *completeButton;
@property (nonatomic, strong) UITextField *resetField;
@property (nonatomic, strong) UITextField *againResetField;
@end
@implementation TZResetPasswordController
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self.navigationItem setTitle:@"重置密码"];
    [self.view endEditing:YES];
    [self setupUI];
}

//更新UI
- (void)setupUI {
    [self addLoginPasswordInController];
    [self addAgreenLoginPasswordInController];
    [self addSuccessButtonInController];
}

//登录密码
- (void)addLoginPasswordInController {
    self.resetPasswordView = [[UIView alloc] init];
    [self.view addSubview:self.resetPasswordView];
    [self.resetPasswordView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view.mas_top).offset(20);
        make.centerX.equalTo(self.view.mas_centerX);
        make.width.mas_equalTo(KSCREEN_WIDTH * 0.8);
        make.height.mas_equalTo(40);
    }];
    //内嵌整体图片
    UIImageView *wholeImageView = [[UIImageView alloc] init];
    [self.resetPasswordView addSubview:wholeImageView];
    [wholeImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.resetPasswordView);
    }];
    wholeImageView.image = [UIImage imageNamed:@"yuan"];
    //内嵌手机图片
    UIImageView *thumbnailImageView = [[UIImageView alloc] init];
    [wholeImageView addSubview:thumbnailImageView];
    [thumbnailImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(wholeImageView.mas_left).offset(11);
        make.height.mas_equalTo(18.5);
        make.width.mas_equalTo(18);
        make.centerY.equalTo(wholeImageView.mas_centerY);
    }];
    thumbnailImageView.image = [UIImage imageNamed:@"mima"];
    //内嵌textField
    UITextField *field = [[UITextField alloc] init];
    [self.resetPasswordView addSubview:field];
    [field mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(thumbnailImageView.mas_right).offset(7);
        make.right.equalTo(wholeImageView.mas_right).offset(-8);
        make.centerY.equalTo(wholeImageView.mas_centerY);
        make.height.mas_equalTo(thumbnailImageView.mas_height);
    }];
    field.placeholder = @"请输入验证码";
    field.font = [UIFont systemFontOfSize:12.0];
    field.textColor = [UIColor blackColor];
    field.clearButtonMode = UITextFieldViewModeWhileEditing;
    self.resetField = field;
}

//二次登录密码
- (void)addAgreenLoginPasswordInController {
    self.againResetPasswordView = [[UIView alloc] init];
    [self.view addSubview:self.againResetPasswordView];
    [self.againResetPasswordView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.resetPasswordView.mas_bottom).offset(20);
        make.centerX.equalTo(self.resetPasswordView.mas_centerX);
        make.width.height.mas_equalTo(self.resetPasswordView);
    }];
    //内嵌整体图片
    UIImageView *wholeImageView = [[UIImageView alloc] init];
    [self.againResetPasswordView addSubview:wholeImageView];
    [wholeImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.againResetPasswordView);
    }];
    wholeImageView.image = [UIImage imageNamed:@"yuan"];
    //内嵌手机图片
    UIImageView *thumbnailImageView = [[UIImageView alloc] init];
    [wholeImageView addSubview:thumbnailImageView];
    [thumbnailImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(wholeImageView.mas_left).offset(11);
        make.height.mas_equalTo(18.5);
        make.width.mas_equalTo(18);
        make.centerY.equalTo(wholeImageView.mas_centerY);
    }];
    thumbnailImageView.image = [UIImage imageNamed:@"mima"];
    //内嵌textField
    UITextField *field = [[UITextField alloc] init];
    [self.againResetPasswordView addSubview:field];
    [field mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(thumbnailImageView.mas_right).offset(7);
        make.right.equalTo(wholeImageView.mas_right).offset(-8);
        make.centerY.equalTo(wholeImageView.mas_centerY);
        make.height.mas_equalTo(thumbnailImageView.mas_height);
    }];
    field.placeholder = @"请输入登录密码";
    field.font = [UIFont systemFontOfSize:12.0];
    field.textColor = [UIColor blackColor];
    field.clearButtonMode = UITextFieldViewModeWhileEditing;
    self.againResetField = field;
}

//完成按钮
- (void)addSuccessButtonInController {
    self.completeButton = [[UIButton alloc] init];
    [self.view addSubview:self.completeButton];
    [self.completeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(self.resetPasswordView);
        make.left.equalTo(self.resetPasswordView);
        make.top.equalTo(self.againResetPasswordView.mas_bottom).offset(20);
    }];
    [self.completeButton setBackgroundImage:[UIImage imageNamed:@"RedButton"] forState:UIControlStateNormal];
    [self.completeButton setBackgroundImage:[UIImage imageNamed:@"RedButtonPressed"] forState:UIControlStateHighlighted];
    [self.completeButton setTitle:@"完成" forState:UIControlStateNormal];
    [self.completeButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.completeButton addTarget:self action:@selector(completeButtonDidClick) forControlEvents:UIControlEventTouchUpInside];
}

//完成按钮监听事件
- (void)completeButtonDidClick {
    TZSuccessLoginController *successLoginController = [[TZSuccessLoginController alloc] init];
    [self.navigationController pushViewController:successLoginController animated:YES];
}
@end
